import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMainWindow, QTableWidgetItem, QLabel, QApplication
from PyQt5.QtCore import Qt, QSize
from client.pages.EmojiWin import *


class EmojiPage(QMainWindow, Ui_EmojiWin):
    def __init__(self):
        super(EmojiPage, self).__init__()
        self.setupUi(self)
        self.tableWidget.verticalScrollBar().style().polish(self.tableWidget.verticalScrollBar())
        self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
        self.emoji = u"😀😁😂😃😄😅😆😉😊😋😎😍😘😗😙😚☺😇😐😑😶😏😣😥😮😯😪😫😴😌😛😜😝😒😓😔😕😲😷😖😞😟😤😢😭😦😧😨😬😰😱😳😵😡😠"
        self.tableWidget.setColumnCount(4)
        self.tableWidget.setRowCount(len(self.emoji)//self.tableWidget.columnCount()+1)
        self.import_emoji()

    def import_emoji(self):
        for i, e in enumerate(self.emoji):
            row = int(i / self.tableWidget.columnCount())
            column = int(i % self.tableWidget.columnCount())
            tableWidgetItem = QTableWidgetItem()
            tableWidgetItem.setSizeHint(QSize(62, 62))
            self.tableWidget.setItem(row, column, tableWidgetItem)
            tableWidgetItem.emojiIcon = QLabel()
            tableWidgetItem.emojiIcon.setText(e)
            tableWidgetItem.emojiIcon.setAlignment(Qt.AlignHCenter|Qt.AlignVCenter)
            self.tableWidget.setCellWidget(row, column, tableWidgetItem.emojiIcon)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    myWin = EmojiPage()
    myWin.show()
    sys.exit(app.exec_())